//--------------------------------------------------------------------------------
// This file is part of the Windows Workflow Foundation Sample Code
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This source code is intended only as a supplement to Microsoft
// Development Tools and/or on-line documentation.  See these other
// materials for detailed information regarding Microsoft code samples.
// 
// THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//--------------------------------------------------------------------------------

using System;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Compiler;

namespace Microsoft.Samples.Workflow.UI
{
    class InteractionGroupActivityValidator : InteractionBaseActivityValidator
    {
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection errors = base.Validate(manager, obj);

            InteractionGroupActivity pageActivity = obj as InteractionGroupActivity;
            if (pageActivity == null)
            {
                throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(InteractionGroupActivity).FullName), "obj");
            }

            foreach (Activity child in pageActivity.EnabledActivities)
            {
                if (!(child is InteractionActivity) && !(child is Navigator))
                {
                    errors.Add(new ValidationError(SR.GetString(SR.Error_ChildMustBeInteraction), ErrorNumbers.Error_ChildMustBeInteraction));
                }
            }
            return errors;
        }
    }
}
